package com.yeqian.attachment.controller;


import com.yeqian.attachment.service.AttachmentService;
import com.yeqian.attachment.entity.AttachmentFile;
import com.yeqian.entity.ResultJson;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;


/**
 * 文件、附件控制器
 */
@RestController
@RequestMapping(Urls.AttachmentFile.ATTACHMENT_FILE)
public class AttachmentController {

    @Resource
    private AttachmentService attachmentService;

    @PostMapping("upload")
    public ResultJson Upload(MultipartFile file){
        AttachmentFile attachmentFile = attachmentService.uploadFile(file, "\\images", null);
        return ResultJson.Success(attachmentFile.getFileName());
    }
}
